package com.lcxw.hxzbapi.dao.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import com.lcxw.hxzbapi.entity.pojo.Gift;

@Component
@Mapper
public interface GiftMapper {

    @Delete({
        "delete from ywpd_gift",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id)throws Exception;

    @Insert({
        "insert into ywpd_gift (id, giftName, ",
        "needCoin, giftStyle, ",
        "giftType, giftIcon, giftBigIcon, flash, ",
        "addTime,enable)",
        "values (#{id,jdbcType=INTEGER}, #{giftName,jdbcType=VARCHAR}, ",
        "#{needCoin,jdbcType=INTEGER}, #{giftStyle,jdbcType=CHAR}, ",
        "#{giftType,jdbcType=CHAR}, #{giftIcon,jdbcType=VARCHAR}, ",
        "#{giftBigIcon}, ",
        "#{flash}, ",
        "#{addTime}, #{enable})"
    })
    int insert(Gift gift)throws Exception;

    /**
     * 通过id查询礼物
     */
    @Select({
        "select",
        "*",
        "from ywpd_gift",
        "where id = #{id,jdbcType=INTEGER}"
    })
    Gift selectByPrimaryKey(Integer id)throws Exception;


    /**
     * 通过giftId查询礼物
     */
    @Select({
        "select",
        "*",
        "from ywpd_gift",
        "where giftId = #{giftId}"
    })
    Gift selectByGiftId(Integer giftId);

    /**
     * 查询所有已经启用的礼物
     */
    @Select("Select * from ywpd_gift order by needcoin asc")
    List<Gift> selectAllGift();


    /**
     * 查询所有已经启用的礼物
     */
    @Select("Select * from ywpd_gift where enable = 1 order by needcoin asc")
    List<Gift> selectAllEnableGift() throws Exception;


    /**
     * 更新礼物，通过id
     */
    @Update({
        "update ywpd_gift",
        "set giftName = #{giftName,jdbcType=VARCHAR},",
        "needCoin = #{needCoin,jdbcType=INTEGER},",
        "giftStyle = #{giftStyle,jdbcType=CHAR},",
        "giftType = #{giftType,jdbcType=CHAR},",
        "giftIcon = #{giftIcon,jdbcType=VARCHAR},",
        "giftBigIcon = #{giftBigIcon,jdbcType=VARCHAR},",
        "flash = #{flash,jdbcType=VARCHAR},",
        "addTime = #{addTime},",
        "enable = #{enable}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Gift gift)throws Exception;



}
